package com.wang.example.protocol;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;

public class BusinessServerHandler  extends ChannelInboundHandlerAdapter {
    /**
     * 服务端读取到网络数据后的处理
     * @param ctx
     * @param msg
     * @throws Exception
     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg)
            throws Exception {
        System.out.println("server receive msg:" + msg);
        //写回客户端
        ctx.channel().writeAndFlush("success");
        ReferenceCountUtil.release(msg); //释放msg
    }

}
